/*     */ package com.iris.egrant.webapp.struts2;
/*     */ 
/*     */

import com.iris.egrant.app.utils.IrisStringUtils;
import com.iris.egrant.remote.http.service.ServiceFactory;
import com.iris.egrant.service.ServiceUtils;
import com.iris.egrant.web.struts2.Struts2Utils;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.catalina.authenticator.SavedRequest;
import org.springframework.web.util.WebUtils;

import javax.annotation.Resource;
import javax.servlet.http.Cookie;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/*     */
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class IndexAction
/*     */   extends ActionSupport
/*     */ {
/*     */   private static final long serialVersionUID = -2700156214728128232L;
///*  38 */   private final RequestCache requestCache = (RequestCache)new HttpSessionRequestCache();
/*     */   
/*     */   @Resource(name = "serviceFactory")
/*     */   private ServiceFactory serviceFactory;
/*     */   
/*     */   private String targetUrl;
/*     */   
/*     */   public String noLoginRequest() {
/*  46 */     Struts2Utils.getSession().setAttribute("token", UUID.randomUUID().toString());
/*  47 */     return "loginWindow";
/*     */   }
/*     */ 
/*     */   
/*     */   public String execute() throws Exception {
///*  52 */     SavedRequest sr = this.requestCache.getRequest(Struts2Utils.getRequest(), Struts2Utils.getResponse());
///*  53 */     if (null != sr) {
///*  54 */       this.targetUrl = sr.getRedirectUrl();
///*     */     }
/*     */     
///*  57 */     if (SecurityUtils.getCurrentUserId().longValue() != 0L) {
///*  58 */       LOG.debug("正在进入首页,已经登录过了...", new String[0]);
///*  59 */       Struts2Utils.getResponse().sendRedirect(Struts2Utils.getRequest().getContextPath() + "/main");
///*  60 */       return "none";
///*     */     }
/*  62 */     LOG.debug("正在进入首页,尚未登录...", new String[0]);
/*     */     
/*  64 */     Cookie cookie = WebUtils.getCookie(Struts2Utils.getRequest(), "isisCasAuth");
/*  65 */     if (cookie != null && "true".equals(cookie.getValue())) {
/*  66 */       Struts2Utils.getResponse().sendRedirect(Struts2Utils.getRequest().getContextPath() + "/main");
/*     */     }
/*  68 */     String validateCode = System.getProperty("wtp.validateCode");
/*  69 */     if ("disable".equals(validateCode)) {
/*  70 */       Struts2Utils.getRequest().getSession().setAttribute("validateCode", "disable");
/*     */     }
/*  72 */     return "index";
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public String checkIsUKey() throws Exception {
/*  81 */     String username = Struts2Utils.getParameter("username");
/*  82 */     String randKey = Struts2Utils.getParameter("randKey");
/*  83 */     Struts2Utils.getSession().setAttribute("randomData", randKey);
///*  84 */     if (!IrisStringUtils.isNullOrBlank(username)) {
///*  85 */       SysUser user = ((SysUserService)this.serviceFactory.getService(SysUserService.class)).findUserByName(username.toLowerCase().trim());
///*     */
///*  87 */       Map<String, Object> map = new HashMap<String, Object>();
///*  88 */       if (user != null) {
///*  89 */         map.put("isUKey", user.getIsukey());
///*  90 */         map.put("ukeypwd", ServiceUtils.encodeToDes3(user.getUkeypwd()));
///*  91 */         map.put("ukeysn", user.getUkeysn());
///*     */       }
///*  93 */       Struts2Utils.getSession().setAttribute("uKey", map);
///*  94 */       Struts2Utils.renderJson(map, new String[] { "encoding:UTF-8" });
///*     */     }
/*     */     
/*  97 */     return null;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public String serviceCheck() throws Exception {
/* 106 */     String pwd = Struts2Utils.getParameter("pwd");
/* 107 */     pwd = ServiceUtils.decodeFromDes3(pwd);
/*     */     
/* 109 */     String randata = (String)Struts2Utils.getSession().getAttribute("randomData");
/* 110 */     String clientDigest = Struts2Utils.getParameter("digest");
///* 111 */     HMAC_MD5 hm = new HMAC_MD5(pwd.getBytes());
///* 112 */     hm.addData(randata.getBytes());
/*     */ 
/*     */     
///* 115 */     byte[] digest = hm.sign();
///* 116 */     String ss = hm.toString();
/*     */     
///* 118 */     if (clientDigest.equals(ss)) {
/* 119 */       Struts2Utils.renderJson(Boolean.valueOf(true), new String[] { "encoding:UTF-8" });
///*     */     } else {
///* 121 */       Struts2Utils.renderJson(Boolean.valueOf(false), new String[] { "encoding:UTF-8" });
///*     */     }
/* 123 */     return null;
/*     */   }
/*     */   
/*     */   public String getTargetUrl() {
/* 127 */     return this.targetUrl;
/*     */   }
/*     */   
/*     */   public void setTargetUrl(String targetUrl) {
/* 131 */     this.targetUrl = targetUrl;
/*     */   }
/*     */ }


/* Location:              D:\文件\123\WEB-INF\classes\!\com\iris\egrant\webapp\struts2\IndexAction.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       1.1.3
 */